package syn;

public class Syn1 implements Runnable {

	public static void main(String[] args) {
		Syn1 program = new Syn1();
		new Thread(program).start();
		program.run_second_thread();
	}

	public void run_second_thread() {
		for (int i = 0; i < 10; i++)
			synchronized (this) {
				display("Bonjour monde\n");
			}
	}

	public void run() {
		for (int i = 0; i < 10; i++)
			synchronized (this) {
				display("Hello world\n");
			}
	}

	static public void display(String s) {
		for (int i = 0; i < s.length(); i++) {
			System.out.print(s.charAt(i));
			try {
				Thread.sleep(5);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
